import axios from 'axios';

export interface AIResult {
  line: number;
  message: string;
  suggestion?: string;
  riskType?: string;
}

/**
 * 调用DeepSeek API进行AI增强检测
 * @param code 代码片段
 * @param fileName 文件名（可选）
 * @param apiKey API密钥
 * @param apiUrl API地址
 */
export async function callDeepSeekAPI(code: string, fileName?: string, apiKey?: string, apiUrl?: string): Promise<AIResult[]> {
  const url = apiUrl || 'https://api.deepseek.com/analyze';
  try {
    const response = await axios.post(url, {
      code,
      fileName
    }, {
      headers: apiKey ? { 'Authorization': `Bearer ${apiKey}` } : undefined
    });
    return response.data.results || [];
  } catch (e) {
    return [];
  }
} 